package cn.appsm.persistance.pageSupport;

/**
 * 分页方言
 * @author flatychen
 * @date 2014-6-12
 * @version 
 */

@Deprecated
public abstract class PageDialect {

	public enum DBMS {
		MYSQL, ORACLE

	}

	

	/**
	 * 得到总数量SQL
	 * @author flatychen
	 * @date 2014-6-12
	 * @param sql
	 * @return
	 * @version 
	 */
	public String getCountSql(String sql){
		return "select count(1) from (" + sql + ") tmp_count";
	}
	
	
	/**
	 * FIXME 存在硬解析
	 * 直接使用数字代替占位符
	 * @author flatychen
	 * @date 2014-6-12
	 * @param sql
	 * @param offset
	 * @param limit
	 * @return
	 * @version 
	 */
	public String getSimplePageSql(String sql, int offset, int limit) {
		return getPageSql(sql, offset, Integer.toString(offset), limit,
				Integer.toString(limit));
	}
	
	
	public String getPlaceHolderPageSql(String sql, int offset, int limit){
		return getPageSql(sql, offset, ":offset", limit,
				":limit");
	}
	
	public abstract String getPageSql(String sql,int offset,String offsetPlaceholder, int limit, String limitPlaceholder);

}
